package com.yidu.view;

import com.yidu.domain.BookUser;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

/**
 * <p>@Description: 测试BookUser</p>
 * <p>@Author yidu-liandyao</p>
 * <p>@Date: 2021-01-05</p>
 * <p>@Time: 10:24</p>
 */
public class BookUserTest {



    public static void main(String[] args) {

        SqlSession session = SqlSessionTools.getSession();

        List<BookUser> list =
                session.selectList("com.yidu.dao.BookUserMapper.selectAll");
        for(BookUser user:list){
            System.out.println(user.getUserName());
        }
        session.close();

    }


    @Test
    public void selectId(){
        SqlSession session = SqlSessionTools.getSession();
        BookUser user = session.selectOne("com.yidu.dao.BookUserMapper.findById",142);
        System.out.println(user.getUserName());
        session.close();

    }


    @Test
    public void add(){
        SqlSession session = SqlSessionTools.getSession();

        BookUser user = new BookUser();
        user.setUserName("烟民2222");
        user.setUserPwd("yanmin");
        int rows = session.insert("com.yidu.domain.BookUser.add",user);
        System.out.println("增加的行数是:"+rows);
        session.commit();//提交事务
        session.close();

    }


}
